<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width"/>
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title>职业意向选择</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/main.css" />
    <link rel="stylesheet" type="text/css" href="../../css/myDevelop.css" />
</head>
<body>
  <div id="header">
      <div id="back"></div>
      <h3>实训方向选择</h3>
  </div>
  <div id="all">
    <div class="tabs">
      <span class="active">实训1方向</span>
      <span>实训3方向</span>
    </div>
    <div class="MyChoose active">
      <!-- <div class="item">
        <div class="pao end">剩余X小时X分X秒</div>
        <div class="title">java方向</div>
        <div class="detail">
          <div><span>开始时间：</span><span>2018-12-11</span></div>
          <div><span>截止时间：</span><span>2018-12-11</span></div>
          <div><span>已选人数：</span><span class="people">22</span></div>
        </div>
        <button class="btn btn-info"  tapmode>进入报名</button>
      </div>
      <div class="item">
        <div class="pao start">距离开始还有X小时X分X秒</div>
        <div class="title">java方向</div>
        <div class="detail">
          <div><span>开始时间：</span><span>2018-12-11</span></div>
          <div><span>截止时间：</span><span>2018-12-11</span></div>
          <div><span>已选人数：</span><span class="people">0</span></div>
        </div>
        <button class="btn btn-info"  tapmode>查看明细</button>
      </div>
      <div class="item">
        <div class="pao close">报名时间已截止</div>
        <div class="title">java方向</div>
        <div class="detail">
          <div><span>开始时间：</span><span>2018-12-11</span></div>
          <div><span>截止时间：</span><span>2018-12-11</span></div>
          <div><span>已选人数：</span><span class="people">22</span></div>
        </div>
        <button class="btn btn-info"  tapmode>查看明细</button>
      </div>
      <div class="item">
        <div class="pao mine">我已选的方向</div>
        <div class="title">java方向</div>
        <div class="detail">
          <div><span>开始时间：</span><span>2018-12-11</span></div>
          <div><span>截止时间：</span><span>2018-12-11</span></div>
          <div><span>已选人数：</span><span class="people">22</span></div>
        </div>
        <button class="btn btn-info"  tapmode>查看明细</button>
      </div> -->
    </div>
    <div class="MyChoose">
      <div class="none">
        实训3暂时没有开放<br>
        请访问PC端大学了没进行操作<br>
        www.xxx.com
      </div>
  </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/jquery.js"></script>
<script type="text/javascript">
apiready=function(){
  var flag=$api.getStorage('flag');
  var aid=$api.getStorage('aid');
  var jwt=$api.getStorage('jwt');
  //查询选择的方向
  api.ajax({
    url: 'http://47.104.170.122/v1/portal/training/student/app/directions?token='+jwt,
    method: 'GET',
    headers: {
      "Access-Control-Allow-Origin": "*",
      "Access-Control-Allow-Headers": "Authorization",
      "Content-Type" : 'application/json; charset=utf-8'
    }
  }, function(ret, err) {
    if(ret.code==0){
      var json=ret.data;
      nowTime=Date.parse(new Date());
      $.each(json,function(i,val){
        var startTime=json[i].startTime;
        var endTime=json[i].endTime;
        var MyChooseTime=json[i].chooseTime;
        if(nowTime-endTime>0){
          var status='报名时间已截止'
          className='close'
        }
        if(startTime-nowTime>0){
          var status='报名未开始'
          className='start'
        }
        if(nowTime-startTime>0&&nowTime-endTime<0){
          var status='可以开始报名啦'
          className='end'
        }
        if(MyChooseTime>startTime&&MyChooseTime<endTime){
          var status='我已选的方向'
          className='mine'
        }
        var template=`<div class="item" id="`+json[i].id+`">
          <div class="pao `+className+`">`+status+`</div>
          <div class="title">`+json[i].name+`</div>
          <div class="detail">
            <div><span>开始时间：</span><span>`+getLocalTime(startTime)+`</span></div>
            <div><span>截止时间：</span><span>`+getLocalTime(endTime)+`</span></div>
            <div><span>已选人数：</span><span class="people">`+json[i].chooseTotal+`</span></div>
          </div>
          <button class="btn btn-info"  tapmode>查看明细</button>
        </div>`;
        $(".MyChoose").append(template)
      })
    }
  });
  $(".tabs span").on("touchstart",function(){
    $(this).addClass("active").siblings().removeClass("active");
    $(".MyChoose").eq($(this).index()).addClass("active").siblings().removeClass("active");
  })
  $(".MyChoose:eq(0)").on("click",".item",function(){
     var type=$(this).index();
     var thisId=$(this).attr("id");
     var status=$(this).find(".pao").html();
     api.openWin({
        name: 'enList',
        url: 'enList.html',
        pageParam: {
            thisId:thisId,
            type: status
        }
    });
  })
}
//jquery
$(function(){
  back();
})
</script>
<script type="text/javascript" src="../../script/main.js"></script>
</html>
